using UnityEditor;
using UnityEngine;

namespace Jerry.UiFrame.Editor
{
    [CustomEditor(typeof(JTextMesh))]
    public class JTextMeshEditor : UnityEditor.Editor
    {
        private SerializedProperty typewriter;
        private SerializedProperty delayTime;
        
        private void OnEnable()
        {
            typewriter = serializedObject.FindProperty("typewriter");
            delayTime = serializedObject.FindProperty("delayTime");
        }
        
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            Color originalColor = GUI.color;
            
            GUI.color = Color.green;
           
            EditorGUILayout.PropertyField(typewriter);
            if (typewriter.boolValue)
            {
                EditorGUILayout.PropertyField(delayTime);
            }

            GUI.color = originalColor;
            serializedObject.ApplyModifiedProperties();

            base.OnInspectorGUI();
        }
    }
}